package com.cskaoyan.controller.admin;

import com.cskaoyan.model.admin.bo.AfterSaleListBO;
import com.cskaoyan.model.admin.bo.BaseParam1;
import com.cskaoyan.model.admin.vo.AfterSaleListRespVO;
import com.cskaoyan.model.admin.vo.BaseRespVo;
import com.cskaoyan.service.admin.AfterSaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName: After
 * @Author: WangEnzhao
 * @Description: 售后服务
 * @CreateTime: 2021/11/22:35:00
 */
@RestController
@RequestMapping("admin/aftersale")
public class AfterSaleController {

    @Autowired
    AfterSaleService afterSaleService;

    /**
    * @Author: WangEnzhao
    * @Description: 售后管理查询数据
    * @CreateTime:
    * @Param:
    * @return:
    **/
    @RequestMapping("list")
    public BaseRespVo selectAfterSaleList(BaseParam1 baseParam, AfterSaleListBO afterSaleListBO){
        AfterSaleListRespVO afterSaleListRespVO = afterSaleService.selectAfterSaleList(baseParam, afterSaleListBO);

        return BaseRespVo.ok(afterSaleListRespVO);
    }


    /***
    * @Author: WangEnzhao
    * @Description: 批量通过申请
    * @CreateTime: 17:35 12/1/2021
    * @Param: []
    * @return: com.cskaoyan.model.admin.vo.BaseRespVo
    */
    @RequestMapping("batch-recept")
    public BaseRespVo batchReceipt(@RequestBody Map<String,Integer[]> map){
        Integer[] ids = map.get("ids");
        afterSaleService.batchReceipt(ids);
        return BaseRespVo.ok(null);
    }

    /***
     * @Author: WangEnzhao
     * @Description: 单个通过申请
     * @CreateTime: 17:35 12/1/2021
     * @Param: []
     * @return: com.cskaoyan.model.admin.vo.BaseRespVo
     */
    @RequestMapping("recept")
    public BaseRespVo receipt(@RequestBody Map map){
        Integer[] ids = new Integer[1];
        ids[0] = (Integer) map.get("id");
        afterSaleService.batchReceipt(ids);
        return BaseRespVo.ok(null);
    }



    /***
    * @Author: WangEnzhao
    * @Description: 批量拒绝申请
    * @CreateTime: 18:52 12/1/2021
    * @Param: [map]
    * @return: com.cskaoyan.model.admin.vo.BaseRespVo
    */
    @RequestMapping("batch-reject")
    public BaseRespVo batchReject(@RequestBody Map<String, Integer[]> map){
        Integer[] ids = map.get("ids");
        afterSaleService.batchReject(ids);
        return BaseRespVo.ok(null);
    }


    /***
     * @Author: WangEnzhao
     * @Description: 单个拒绝申请
     * @CreateTime: 18:52 12/1/2021
     * @Param: [map]
     * @return: com.cskaoyan.model.admin.vo.BaseRespVo
     */
    @RequestMapping("reject")
    public BaseRespVo reject(@RequestBody Map map){
        Integer[] ids = new Integer[1];
        ids[0] = (Integer) map.get("id");
        afterSaleService.batchReject(ids);
        return BaseRespVo.ok(null);
    }
}
